home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / edit / tecoc-146.lha / exedqu.c < prev    next >
C/C++ Source or Header  |  1991-07-05  |  4KB  |  151 lines

  1. /*****************************************************************************
  2.  
  3.     ExeDQu()
  4.  
  5.     This function executes a " (double-quote) command.
  6.  
  7.     "    Start conditional
  8.     n"<    Text for less than zero
  9.     n"=    Test for equal to zero
  10.     n">    Test for greater than zero
  11.     n"A    Test for alphabetic
  12.     n"C    Test for symbol constituent
  13.     n"D    Test for numeric
  14.     n"E    Test for equal to zero
  15.     n"F    Test for false
  16.     n"G    Test for greater than zero
  17.     n"L    Test for less than zero
  18.     n"N    Test for not equal to zero
  19.     n"R    Test for alphanumeric
  20.     n"S    Test for successful
  21.     n"T    Test for true
  22.     n"U    Test for unsuccessful
  23.     n"V    Test for lower case
  24.     n"W    Test for upper case
  25.  
  26. *****************************************************************************/
  27.  
  28. #include "zport.h"        /* define portability identifiers */
  29. #include "tecoc.h"        /* define general identifiers */
  30. #include "defext.h"        /* define external global variables */
  31. #include "deferr.h"        /* define identifiers for error messages */
  32. #include "chmacs.h"        /* define character processing macros */
  33.  
  34. DEFAULT ExeDQu()        /* execute a " (double quote) command */
  35. {
  36.     unsigned char RelExp;            /* relational expression */
  37.  
  38.     DBGFEN(1,"ExeDQu",NULL);
  39.     if (EStTop == EStBot) {            /* if no numeric argument */
  40.         ErrMsg(ERR_NAQ);        /* no argument before " */
  41.         DBGFEX(1,DbgFNm,"FAILURE");
  42.         return FAILURE;
  43.     }
  44.  
  45.     if (GetNmA() == FAILURE) {
  46.         DBGFEX(1,DbgFNm,"FAILURE, GetNmA() failed");
  47.         return FAILURE;
  48.     }
  49.  
  50.     if (IncCBP() == FAILURE) {
  51.         DBGFEX(1,DbgFNm,"FAILURE, IncCBP() failed");
  52.         return FAILURE;
  53.     }
  54.     CmdMod = '\0';
  55.     RelExp = (unsigned char)NArgmt;
  56.  
  57.     switch (To_Upper(*CBfPtr)) {
  58.     case 'A':    /* test for alphabetic */
  59.         if (Is_Alpha(RelExp)) {
  60.             DBGFEX(1,DbgFNm,"SUCCESS, Is_Alpha");
  61.             return SUCCESS;
  62.         }
  63.         break;
  64.  
  65.     case 'C':    /* test for symbol constituent */
  66.         if (Is_SyCon(RelExp)) {
  67.             DBGFEX(1,DbgFNm,"SUCCESS, Is_SyCon");
  68.             return SUCCESS;
  69.         }
  70.         break;
  71.  
  72.     case 'D':    /* test for numeric */
  73.         if (Is_Digit(RelExp)) {
  74.             DBGFEX(1,DbgFNm,"SUCCESS, Is_Digit");
  75.             return SUCCESS;
  76.         }
  77.         break;
  78.  
  79.     case 'E':    /* test for equal to zero */
  80.     case 'F':    /* test for false */
  81.     case 'U':    /* test for unsuccessful */
  82.     case '=':    /* test for equal to zero */
  83.         if (NArgmt == 0) {
  84.             DBGFEX(1,DbgFNm,"SUCCESS, equal to zero");
  85.             return SUCCESS;
  86.         }
  87.         break;
  88.  
  89.     case 'G':    /* test for greater than zero */
  90.     case '>':    /* test for greater than zero */
  91.         if (NArgmt > 0) {
  92.             DBGFEX(1,DbgFNm,"SUCCESS, greater than zero");
  93.             return SUCCESS;
  94.         }
  95.         break;
  96.  
  97.     case 'L':    /* test for less than zero */
  98.     case 'S':    /* test for successful */
  99.     case 'T':    /* test for TRUE */
  100.     case '<':    /* test for less than zero */
  101.         if (NArgmt < 0) {
  102.             DBGFEX(1,DbgFNm,"SUCCESS, less than zero");
  103.             return SUCCESS;
  104.         }
  105.         break;
  106.  
  107.     case 'N':    /* test for not equal to zero */
  108.         if (NArgmt != 0) {
  109.             DBGFEX(1,DbgFNm,"SUCCESS, not equal to zero");
  110.             return SUCCESS;
  111.         }
  112.         break;
  113.  
  114.     case 'R':    /* test for alphanumeric */
  115.         if (Is_Alnum(RelExp)) {
  116.             DBGFEX(1,DbgFNm,"SUCCESS, Is_Alnum");
  117.             return SUCCESS;
  118.         }
  119.         break;
  120.  
  121.     case 'V':    /* test for lowercase */
  122.         if (Is_Lower(RelExp)) {
  123.             DBGFEX(1,DbgFNm,"SUCCESS, Is_Lower");
  124.             return SUCCESS;
  125.         }
  126.         break;
  127.  
  128.     case 'W':    /* test for uppercase */
  129.         if (Is_Upper(RelExp)) {
  130.             DBGFEX(1,DbgFNm,"SUCCESS, Is_Upper");
  131.             return SUCCESS;
  132.         }
  133.         break;
  134.  
  135.     default:
  136.         ErrMsg(ERR_IQC);        /* ill. char. after " */
  137.         DBGFEX(1,DbgFNm,"FAILURE");
  138.         return FAILURE;
  139.     }
  140.  
  141.     if (FlowEE() == FAILURE) {        /* flow to | or ' */
  142.         DBGFEX(1,DbgFNm,"FAILURE, FlowEE() failed");
  143.         return FAILURE;
  144.     }
  145.  
  146.     CmdMod = '\0';                /* clear modifiers flags */
  147.  
  148.     DBGFEX(1,DbgFNm,"SUCCESS, test failed");
  149.     return SUCCESS;
  150. }
  151.